package com.example.mygrade.core;

import com.example.mygrade.exception.REnum;
import com.example.mygrade.vo.R;

/**
 * 对R对象进行简化
 */
public class RUtil {
    public static R success(Object object,String message){
        R result = new R();
        result.setCode(200);
        result.setData(object);
        result.setMsg(message);

        return result;
    }


    public static R success(){
        return success(null,null);
    }

    public static R error(Integer code,String msg){
        R result = new R();
        result.setCode(code);
        result.setData(null);
        result.setMsg(msg);

        return result;
    }

    public static R error(REnum rEnum){
        return error(rEnum.getCode(),rEnum.getMsg());
    }
}
